#include "VoERTPObserverImpl.h"


VoERTPObserverImpl::VoERTPObserverImpl(void)
{
	m_mid_OnIncomingCSRCChanged = 0;
	m_mid_OnIncomingSSRCChanged = 0;
}


VoERTPObserverImpl::~VoERTPObserverImpl(void)
{
}

bool VoERTPObserverImpl::init_jni(JNIEnv* env)
{
	bool result = false;

	do 
	{
		m_mid_OnIncomingCSRCChanged = (env)->GetMethodID(m_cls, "onIncomingCSRCChanged", "(IIZ)V");
		if(!m_mid_OnIncomingCSRCChanged)
			break;

		m_mid_OnIncomingSSRCChanged = (env)->GetMethodID(m_cls, "onIncomingSSRCChanged", "(II)V");
		if(!m_mid_OnIncomingSSRCChanged)
			break;

		result = true;

	} while (false);

	return result;
}

void VoERTPObserverImpl::OnIncomingCSRCChanged(
	const int channel, const unsigned int CSRC, const bool added)
{
	JNIEnv* env = 0;

	if(before(&env))
	{
		(env)->CallVoidMethod(m_obj, m_mid_OnIncomingCSRCChanged, channel, CSRC, added);

		after(env);
	}
}

void VoERTPObserverImpl::OnIncomingSSRCChanged(
	const int channel, const unsigned int SSRC)
{
	JNIEnv* env = 0;

	if(before(&env))
	{
		(env)->CallVoidMethod(m_obj, m_mid_OnIncomingSSRCChanged, channel, SSRC);

		after(env);
	}
}